// 新增型号
import React from 'react';
import './addNewType.scss';
import AreaData from '../../../component/areaData/areaData.js'; //地址库
import utils from '../../../utils/utils';
import BMap from 'BMap';
import moment from 'moment';
import BreadcrumbNav from '../../../component/breadcrumb/breadcrumb.js';
import { Row, Col, Button, Form , Tooltip,Select, Input, Upload , InputNumber ,Image,Radio,Modal, message} from 'antd';
import cookie from 'react-cookies'
import { UploadOutlined ,DeleteTwoTone,EditTwoTone,DeleteOutlined,LoadingOutlined,PlusOutlined} from '@ant-design/icons';
import {updEqModel,brandList, categoryList,addEqModel,fittingList,eqModelDetail} from '../../../api/deviceLibrary'
import { getAttach} from '../../../api/extra'
import {getUserListByMenu} from '../../../api/accountManage'
const { Option } = Select;

class addNewType extends React.Component {
    addNewTypeForm = React.createRef()
    addCarForm= React.createRef()
    state = {
        gg_list:[], // 规格信息
        addESAModal:false,
        brand_list:[], // 设备品牌列表
        name:'', // 设备类型
        id:'', // 设备类型id
        activeDetele:null,
        fileList:[], // PDF上传文件
        fileListImg: [],//  图片
        instructions_ids:[], // pdf文件id集合,
        eq_img_ids:[], // 图片id集合
        arrival_period_unit:'1',
        user_list:[],// 复核人集合
        type:'', // 设备还是配件  1设备2配件
        review_u_name:'', // 复核人的名字
        list:[],// 配件列表
        spu_arr:[], // 配件子类列表
        dataObj:{},
        img_url:[],
        wx:false,// 是否是维修
        addNewGG:{}, // 弹框显示的key-value
        spu_id:'', // 维修id
        myDeclare:false
    }

    componentDidMount() {
        this.GetRequest(this.props.location.state)
        this.getcategoryList()
        this.CGLRgetUserListByMenu()
    }
    componentDidUpdate(){
       
    }
    // window跳转
    GetRequest=(theRequest)=> {
        if(theRequest.myDeclare){
            // 我的申报编辑跳转过来的
            this.getEqModelDetail(theRequest.spu_id)
            this.setState({myDeclare:true,wx:false, spu_id:theRequest.spu_id})
        } else if(theRequest.spu_id) {
            // 信息维护
            this.getEqModelDetail(theRequest.spu_id)
            this.setState({wx:true, spu_id:theRequest.spu_id,myDeclare:false})
        } else {
            // 新增跳转过来的
            this.getBrandList(theRequest.Id)
            this.setState({name:theRequest.name,id:theRequest.Id,type:theRequest.type})
            this.addNewTypeForm.current.setFieldsValue({cate_name:theRequest.name})
            if(theRequest.type == 2) {
                this.addNewTypeForm.current.setFieldsValue({has_fittings:'2'})
            }
            this.setState({wx:false,myDeclare:false})
        }
        this.addNewTypeForm.current.setFieldsValue({user_name:cookie.load('station_console_setting_web_login').user_name})
    }
    // 设备品牌详情
    getEqModelDetail=(spu_id)=>{
        let _this = this
        let {gg_list} = this.state
        let post_data = {
            'auth_token': cookie.load('station_console_setting_web_login').auth_token,
            spu_id
        }
        eqModelDetail(post_data).then(res=>{
            res.data.spec_info.forEach((item,index)=>{
                item.index = index + 1
            })
            this.setState({
                dataObj:res.data,
                gg_list:res.data.spec_info,
                eq_img_ids:res.data.eq_img_ids.split(',')  ,
                instructions_ids:res.data.instructions_ids.split(','),
                img_url:res.data.img_url,
                fileList:res.data.instructions_url,
                id:res.data.cate_id
            },()=>{
                this.getBrandList(res.data.brand_id)
            })

            res.data.is_offer = res.data.is_offer + ''
            res.data.arrival_period_unit = res.data.arrival_period_unit + ''
            res.data.transport_type = res.data.transport_type + ''
            res.data.has_fittings = res.data.has_fittings + ''
           
        })
    }
    getFittingList=()=>{
        let post_data = {
            'auth_token': cookie.load('station_console_setting_web_login').auth_token,
        }
        fittingList(post_data).then(res=>{
            this.setState({
                list:res.data.list
            })
        })
    }
    // 设备品牌
    getBrandList=(id)=>{
        let post_data = {
            'auth_token': cookie.load('station_console_setting_web_login').auth_token,
            id
        }
        brandList(post_data).then(res=>{
            if(res.code == 0) {
                this.setState({brand_list:res.data.brand_list})
            }
            this.addNewTypeForm.current.setFieldsValue(this.state.dataObj)
            if(res.data.brand_list.length == 0 && this.state.wx){
                this.addNewTypeForm.current.setFieldsValue({'brand_id':this.state.dataObj.brand_name})
            }
        })
    }
    // 采买人列表
    CGLRgetUserListByMenu=()=>{
        let post_data = {
            'auth_token': cookie.load('station_console_setting_web_login').auth_token,
            'menu_tag':'my_approve'
        }
        getUserListByMenu(post_data).then(res=>{
            this.setState({user_list:res.data.user_list})
        })
    }
    // 设备类型列表
    getcategoryList=()=>{
        let post_data = {
            'auth_token': cookie.load('station_console_setting_web_login').auth_token,
        }
        categoryList(post_data).then(res=>{
            this.setState({
                list:res.data.list
            })
        })
    }
    reqAddNewGG=()=>{
        let {addNewGG,gg_list} = this.state
        let {spec_value2,spec_value,spec_key} = this.addCarForm.current.getFieldsValue()
        if(this.chack_name(spec_value2)) {
            message.error('格式不正确。只能使用‘/’符号。作为规格分界线。')
            return
        } else {
            let obj = {}
            obj.spec_value = spec_value + '/' +spec_value2
            obj.spec_key = spec_key
            obj.index = addNewGG.index
            let newArr = gg_list.filter(item=>item.index != addNewGG.index)
            newArr.push(obj)
            message.success('修改成功')
            this.setState({addESAModal:false,gg_list: newArr,addNewGG:{}})
            this.addCarForm.current.resetFields()
        }
    }
    // 新增
    subDeclare=()=>{
        let {id,gg_list,wx,instructions_ids, eq_img_ids,arrival_period_unit,ishasFittings, type,name,review_u_name} = this.state
        let { brand_id,eq_model,is_offer,advice_price,arrival_period,buy_channel,
            buy_link,contact_type,contact_name,contact_phone,transport_type,transport_remark,
            has_fittings,review_u_id,cate_id, fitting_spu_id
            } = this.addNewTypeForm.current.getFieldsValue()
        // 验证
        if(!brand_id) {
            message.error('请选择设备品牌id')
            return
        }
        if(!eq_model) {
            message.error('请输入设备品牌名称')
            return
        }
        if(!is_offer) {
            message.error('请选择是否可选用')
            return
        }
        if(gg_list.length == 0) {
            message.error('请填写设备规格')
            return
        }
        if(!has_fittings) {
            message.error('请选择有无配件')
            return
        }
        if(!review_u_id) {
            message.error('请选择复核人')
            return
        }
        if(type == 1 && ishasFittings == 1 ) {
            if(!cate_id) {
                message.error('请选择配件分类')
                return
            }
            if(!fitting_spu_id) {
                message.error('请选择设备编号')
                return
            }
        }
        let newarr = []
        let obj = {}
        obj.cate_id = cate_id
        obj.fitting_spu_id = fitting_spu_id
        newarr.push(obj)
        // 请求
        let post_data = {
            'auth_token': cookie.load('station_console_setting_web_login').auth_token,
            cate_id:id,
            brand_id, // 设备品牌id
            eq_model, // 设备型号name
            'spec':JSON.stringify(gg_list), // 规格信息
            is_offer,
            'instructions_ids':instructions_ids.join(','), // 说明书
            'eq_img_ids':eq_img_ids.join(','), // 图片
            arrival_period_unit, // 到货周期
            advice_price,
            arrival_period,
            buy_channel,
            buy_link,
            contact_type,
            contact_name,
            contact_phone,
            transport_type,
            transport_remark, // 运输方式备注
            has_fittings,
            review_u_id,
            review_u_name,
            'fittings_arr':JSON.stringify(newarr)
        }
        addEqModel(post_data).then(res=>{
            if(res.code == 0) {
                message.success('操作成功')
                this.setState({
                    fileList:[], // PDF上传文件
                    fileListImg: [],//  图片
                    instructions_ids:[], // pdf文件id集合,
                    eq_img_ids:[], // 图片id集合
                    gg_list:[]
                })
                this.addNewTypeForm.current.resetFields()
                this.addNewTypeForm.current.setFieldsValue({cate_name:name})
                if(type == 2) {
                    this.addNewTypeForm.current.setFieldsValue({has_fittings:'2'})
                }
                this.addNewTypeForm.current.setFieldsValue({user_name:cookie.load('station_console_setting_web_login').user_name})
            } else {
                message.error('操作失败')
            }
            
        })
    }
    // 修改
    revise=()=>{
        let _this = this
        let {dataObj,myDeclare,gg_list,wx,instructions_ids, eq_img_ids,arrival_period_unit,spu_id, type,name,review_u_name} = this.state
        let { brand_id,eq_model,is_offer,advice_price,arrival_period,buy_channel,
            buy_link,contact_type,contact_name,contact_phone,transport_type,transport_remark,
            has_fittings,review_u_id,cate_id, fitting_spu_id
            } = this.addNewTypeForm.current.getFieldsValue()
        if(!is_offer) {
            message.error('请选择是否可选用')
            return
        }
        if(gg_list.length == 0) {
            message.error('请填写设备规格')
            return
        }
        // 请求
        let post_data = {
            'auth_token': cookie.load('station_console_setting_web_login').auth_token,
            'spu_id':dataObj.spu_id,
            'spec':JSON.stringify(gg_list), // 规格信息
            is_offer,
            'instructions_ids':instructions_ids.join(','), // 说明书
            'eq_img_ids':eq_img_ids.join(','), // 图片
            arrival_period_unit, // 到货周期
            advice_price,
            arrival_period,
            buy_channel,
            buy_link,
            contact_type,
            contact_name,
            contact_phone,
            transport_type,
            transport_remark, // 运输方式备注
            has_fittings
        }
        updEqModel(post_data).then(res=>{
            if(res.code == 0) {
                message.success('修改成功')
                // 维修信息
                setTimeout(() => {
                    if(_this.state.myDeclare){
                        
                        // window.location.href='/index/myWork/myDeclare'
                        this.props.history.push('/index/myWork/myDeclare')
                    } else {
                        // window.location.href=`/index/deviceLibrary/deviceInfo?Id=${spu_id}`
                        this.props.history.push({
                            pathname: '/index/deviceLibrary/deviceList/deviceInfo',
                            state:{ relative_id: spu_id,look:'true'}})
                    }
                }, 0);
            } else {
                message.success('修改失败')
            }
        })
    }
    // 上传PDF
    getUpLoadUrlPDF = () => {
        const {instructions_ids,fileList} = this.state
        const UpImgUrl = JSON.parse(sessionStorage.getItem('urlConfig')).attach.upload_url;
        const _this = this;
        const props = {
            showUploadList: true,
            customRequest(option) {
                const post_data = {
                    upUrl: UpImgUrl,
                    file: option.file,
                    file_type:2
                }
                getAttach(post_data).then(res => {
                    if(res.code == 0) {
                        message.success('上传文件成功')
                        setTimeout(() => {
                            let newArray = [..._this.state.fileList]
                            newArray[newArray.length - 1].attach_id = res.data.attach_id
                            _this.setState({instructions_ids:[...instructions_ids,res.data.attach_id],
                                fileList:newArray
                            })
                        },0);
                    } else {
                        message.error('上传文件失败')
                    }
                })
            },
            beforeUpload: file => {
                return new Promise((resolve, reject) => {
                    let fileName = file.name;
                    //截取文件名
                    let pointPos = fileName.indexOf('.');
                    fileName = fileName.substr(pointPos+1);
                    //判断文件是否符合正则表达式的规则
                    if (fileName.indexOf('pdf') == -1) {
                        message.error('上传类型必须为PDF文件')
                        return reject(false)
                     }
                    return resolve(true);
                  })
              },
            onChange({ fileList }) {
                _this.setState({ fileList })
                let file = fileList[fileList.length -1 ]
                if(file) {
                    file.status = 'done'
                }
            },
            onRemove(val) {
                let newArr = instructions_ids.filter(item => item != val.attach_id)
                let newArr2 = fileList.filter(item => item.attach_id != val.attach_id)
                _this.setState({
                    instructions_ids: newArr,
                    fileList:newArr2
                })
            }
        }
        return props;
    }
    // 上传图片
    getUpLoadUrl = () => {
        const {eq_img_ids,fileListImg} = this.state
        const UpImgUrl = JSON.parse(sessionStorage.getItem('urlConfig')).attach.upload_url;
        const _this = this;
        const props = {
            showUploadList: true,
            customRequest(option) {
                const post_data = {
                    upUrl: UpImgUrl,
                    file: option.file,
                    file_type:1
                }
                getAttach(post_data).then(res => {
                    if(res.code == 0) {
                        message.success('上传文件成功')
                        setTimeout(() => {
                            let newArray = [..._this.state.fileListImg]
                            newArray[newArray.length - 1].attach_id = res.data.attach_id
                            _this.setState({eq_img_ids:[...eq_img_ids,res.data.attach_id],
                                fileListImg:newArray
                            })
                        },0);
                    } else {
                        message.error('上传文件失败')
                    }
                })
            },
            beforeUpload: file => {
                return new Promise((resolve, reject) => {
                    if (!/\.(jpg|jpeg|png|GIF|JPG|PNG)$/.test(file.name)) {
                        message.error('上传类型必须为图片')
                        return reject(false)
                     }
                    return resolve(true);
                  })
              },
            onChange({ fileList }) {
                _this.setState({ fileListImg:fileList})
                let file = fileList[fileList.length -1 ]
                if(file) {
                    file.status = 'done'
                }
            },
            onRemove(val) {
                let newArr = eq_img_ids.filter(item => item != val.attach_id)
                let newArr2 = fileListImg.filter(item => item.attach_id != val.attach_id)
                _this.setState({
                   eq_img_ids: newArr,
                   fileListImg:newArr2
                })
            }
        }
        return props;
    }
    handleChange = ({ fileList }) => this.setState({ fileList });
    // 判断符号
    chack_name=(str)=>{
            let pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\]<>《》?~！@#￥……&*（）——|{}【】‘；：”“'。，、？ ]");
            if (pattern.test(str)){
        　　　　return true;
        　　}
    }
    // 删除规格信息
    deleteSpec=(index)=>{
        let {gg_list} = this.state
        let newArr = gg_list.filter(item=> item.index != index)
        this.setState({gg_list:newArr})
    }
    // 修改
    specAud=(val)=>{
        this.deleteSpec(val.index)
        // this.setState({activeDetele:val.index})
        this.addNewTypeForm.current.setFieldsValue({spec_value:val.spec_value,spec_key:val.spec_key})
    }
    addgg=()=>{
        let {spec_value, spec_key} = this.addNewTypeForm.current.getFieldsValue()
        let {gg_list} = this.state
        if(!spec_value) {
            message.error('请输入规格类别')
            return
        }
        if(this.chack_name(spec_value)) {
            message.error('请输入规格信息格式不正确。')
            return
        }   
        if(!spec_key) {
            message.error('请输入规格的值')
            return
        }
        let obj = {}
        let newArr = []
        obj.spec_value = spec_value
        obj.spec_key = spec_key
        obj.index = gg_list.length + 1
        newArr = [...gg_list,obj ]
        // gg_list.push(obj)
        this.setState({gg_list:newArr})
        this.addNewTypeForm.current.setFieldsValue({spec_value:''})
        this.addNewTypeForm.current.setFieldsValue({spec_key:''})
    }
    changeCCr=(val,val2)=>{
        this.setState({review_u_name:val2.children})
    }
    changeDHZQ=(val)=>{
        this.setState({arrival_period_unit:val})
    }
    hasFittings=(val)=>{
        this.setState({ishasFittings:val.target.value})
        this.getFittingList()
    }
    checkPhone=(val)=> {
        if (!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(val))) {
            message.error('手机号格式错误')
            return
        }
    }
    // 配件子类列表选择
    onfsiChange=(val,val2)=>{
        let {list} = this.state
        if(val) {
            let newArr = list.filter(item=>item.id == val )
            this.setState({
                spu_arr:newArr[0].spu_arr
            })
        } else {
            this.setState({
                spu_arr:[]
            })
        }

    }
    wsAdd=(val)=>{
        this.setState({addESAModal:true,addNewGG:val},
            ()=>{
                this.addCarForm.current.setFieldsValue(val)
            })
    }
    // 返回
    goBack=()=>{
        console.log(this.state.wx,'111111',this.state.spu_id);
        if(this.state.myDeclare){
            // window.location.href='/index/myWork/myDeclare'
            this.props.history.push({
                pathname: '/index/myWork/myDeclare'})
        } else if(this.state.wx) {
            // window.location.href=`/index/deviceLibrary/deviceInfo?Id=${this.state.spu_id}`
            this.props.history.push({
                pathname: '/index/deviceLibrary/deviceList/deviceInfo',
                state:{ relative_id: this.state.spu_id,look:'true'}})
        } else {
            this.props.history.push({
                pathname: '/index/deviceLibrary/deviceList'})
            // window.location.href='/index/deviceLibrary/deviceList'
        }
    }
    // 删除图片
    deleteImg=(val)=>{
        let {img_url,eq_img_ids} = this.state
        let newArr = eq_img_ids.filter((item,index)=>index != val)
        let newArr2 = img_url.filter((item,index)=>index != val)
        this.setState({img_url:newArr2,eq_img_ids:newArr},()=>{
            message.success('删除成功')
        })
    }
    render() {
        let {gg_list,myDeclare,wx,img_url,ishasFittings,list,spu_arr,type,activeDetele,user_list,fileList,fileListImg,brand_list ,addESAModal} = this.state
        const uploadButton = (
            <div>
                <PlusOutlined />
                <div style={{ marginTop: 8 }}>点击上传图片</div>
            </div>
          );
        return (
            <div className="controlPancel_home">
                {/* <Button type='primary' style={{height:40,width:80,textAlign:'center'}} onClick={()=>this.props.history.go(-1)}>返回</Button> */}
                <Row className="cb_report">
                    <Col span={24}>
                        <div >
                            <Row>
                                <Col span={12} className="titleInfo">
                                    <div className="divfirstchild"></div>
                                    <div className="divlastchild"><span> {wx ?'修改型号':'新增型号'} </span></div>
                                </Col>
                                {/* <Col span={12} className="btn"> <Button icon={<PlusOutlined />} style={{float:'right'}} onClick={()=>{this.setState({addESAModal:true})}}> 添加品牌</Button></Col> */}
                            </Row>  
                        </div>
                        <div className="cb_form">
                        <Form 
                            ref={this.addNewTypeForm}
                            className="noC_form"
                            >
                                {/* 运输物品 */}
                                <Row>
                                    <Col span={6} style={{marginRight:'20px'}}>
                                        <Form.Item
                                            name="cate_name"
                                            label="设备类型 "
                                            rules={[
                                                {
                                                required: true,
                                                }
                                            ]}
                                            >
                                            <Input  allowClear disabled />
                                        </Form.Item>
                                    </Col>
                                    <Col span={6} style={{marginRight:'20px'}}>
                                        <Form.Item
                                                name="brand_id"
                                                label="设备品牌"
                                                rules={[
                                                    {
                                                    required: true,
                                                    },
                                                ]}
                                                >
                                                <Select placeholder="请选择设备品牌" disabled={wx} allowClear>
                                                    { brand_list.map((val, ind) => ( <Option value={ val.bd_id } key={ val.bd_id }>{ val.bd_name }</Option> ))}
                                                </Select>
                                        </Form.Item>
                                    </Col>
                                    <Col span={6} style={{marginRight:'20px'}}>
                                            <Form.Item
                                                    name="eq_model"
                                                    label="设备型号 "
                                                    rules={[
                                                        {
                                                        required: true,
                                                        },
                                                    ]}
                                                    >
                                                    <Input allowClear placeholder="请选择设备型号" disabled={wx} />
                                            </Form.Item>
                                        </Col>         
                                </Row>
                                <Form.Item name="is_offer" label="提供选用" rules={[{ required: true, message: '请选择提供选用方式' }]}>
                                        <Radio.Group onChange={this.JConChange}>
                                            <Radio value="1">可选用</Radio>
                                            <Radio value="2">不可选用</Radio>
                                        </Radio.Group>
                                </Form.Item> 
                                 {/* 分隔符 */}
                                <div className="henLine"></div>
                                {/* 设备规格 */}
                                <Form.Item
                                    label="设备规格"
                                    style={{
                                        marginBottom: 0,
                                        width:'60%'
                                    }}
                                    className="justOne"
                                    >
                                     { wx ? '' : <>  
                                    <Form.Item
                                        name="spec_key"
                                        style={{
                                        display: 'inline-block',
                                        width: 'calc(30% - 12px)',
                                        }}
                                    >
                                        <Input allowClear placeholder="规格类别" />
                                    </Form.Item>
                                    <span
                                        style={{
                                        display: 'inline-block',
                                        width: '24px',
                                        lineHeight: '32px',
                                        textAlign: 'center',
                                        }}
                                    >
                                        -
                                    </span>
                                    <Form.Item
                                        name="spec_value"
                                        style={{
                                        display: 'inline-block',
                                        width: 'calc(55% - 12px)',
                                        }}
                                    >
                                        <Input allowClear placeholder="每个规格见使用 “/” 符号进行分隔,例如: 红色/白色/黑色" />
                                    </Form.Item>
                                    <Button type='primary' style={{marginLeft:'30px',padding:'10px',lineHeight:'3px',borderRadius:'5px'}} onClick={this.addgg}>添加规格</Button>
                                    </>}      
                                    </Form.Item>
                                
                                <div className="addForm">
                                    <div className="addFormItem">
                                        {gg_list.map(item=>(
                                            <div className="itemdiv" key={item.index}>
                                                <Button key={item.index} style={{backgroundColor: (activeDetele == item.index) ? "#fff" : "", border:0,cursor:'auto', padding:'6px 10px'}}  disabled={false} >
                                                    <span>规格: {item.spec_key} -- {item.spec_value}</span>
                                                    {wx ? '' : <>
                                                    {/* 修改信息 */}
                                                    <EditTwoTone onClick={this.specAud.bind(this,item)} style={{marginLeft:'12px',cursor:'pointer'}}  /> 
                                                    {/* 删除 */}
                                                    <DeleteTwoTone onClick={this.deleteSpec.bind(this,item.index)} style={{marginLeft:'12px',cursor:'pointer'}}/> </>}
                                                    {/* 明天来了以后  开始写弹框里的添加规格 */}
                                                    {wx ? 
                                                    <a onClick={this.wsAdd.bind(this,item)} style={{marginLeft:'12px',cursor:'pointer'}}>添加规格</a> : ''}
                                                </Button>
                                            </div>
                                        ))}
                                    </div>
                                    
                                </div>     
                                
                                <div className="henLine"></div>
                                {/* 上传 */}
                                <Row>
                                    <Col className="iii" span={24} style={{marginBottom:20,display:'flex'}}>
                                        <span style={{marginRight:15}}>说明书: </span>
                                        <Upload
                                            {...this.getUpLoadUrlPDF()}
                                            showUploadList
                                            fileList={fileList}
                                            progress={false}
                                            style={{display:'flex'}}
                                            >
                                               <Button style={{padding:'10px 24px 28px 24px',borderRadius:'6px', marginLeft:6,marginRight:10}} icon={<UploadOutlined />} >说明书上传</Button>     
                                        </Upload>
                                    </Col>
                                    <Col style={{display:'flex' }} className="iii" span={24}>
                                        <div style={{width:78}}>设备图片: </div>
                                        {img_url.map((item,index)=>(
                                            <div className="recommends-content-item">
                                                <Image 
                                                        key={item}
                                                        src={item}
                                                        width={106}
                                                        height={106}
                                                        style={{marginRight:10, 
                                                                border: '0.025rem solid #d9d9d9',
                                                                boxSizing: 'border-box',
                                                                borderRadius:'0.05rem'}}
                                                        ></Image>
                                                    <Tooltip title="删除图片">
                                                        <DeleteOutlined onClick={this.deleteImg.bind(this,index)} className="recommends-content-item__info" style={{position:'absolute',top:'50%',left:'50%',transform: 'translate(-50%, -30%)',backgroundColor:'rgba(94, 89, 89, 0.8)'}} />
                                                    </Tooltip>
                                            </div>
                                            ))}
                                        <Upload
                                            {...this.getUpLoadUrl()}
                                            listType="picture-card"
                                            showUploadList
                                            max={10}
                                            fileList={fileListImg}
                                            progress={false}
                                            >
                                               {fileListImg.length > 10 ? null : uploadButton}    
                                        </Upload>
                                    </Col>
                                </Row>
                                {/* 分隔符 */}
                                <div className="henLine"></div>
                                {/* 报价 */}
                                <Row>
                                    <Col span={5}>
                                        <Form.Item
                                            label="建议报价"
                                            name="advice_price"
                                            style={{paddingLeft:'11px'}}
                                        >
                                            <InputNumber style={{width:'100%'}} allowClear suffix="元/台" placeholder="请输入采购金额"/>
                                         </Form.Item>
                                    </Col>
                                    <Col span={5} offset={1}>
                                    <Form.Item label="到货周期">
                                        <Input.Group style={{display:'flex'}} compact>
                                            <Form.Item
                                                name='arrival_period_unit'
                                                noStyle
                                            >
                                                <Select defaultValue="1" placeholder="到货周期" onChange={this.changeDHZQ}>
                                                    <Option value="1">天</Option>
                                                    <Option value="2">周</Option>
                                                    <Option value="3">月</Option>
                                                    <Option value="4">年</Option>
                                                </Select>
                                            </Form.Item>
                                            <Form.Item
                                                name='arrival_period'
                                                noStyle
                                            >
                                                <Input allowClear  placeholder="请输入到货周期"/>
                                            </Form.Item>
                                        </Input.Group>
                                        </Form.Item> 
                                    </Col>
                                </Row>
                                {/* 联系人 */}
                                <Form.Item
                                    label="联系人"
                                    style={{
                                        paddingLeft:11,
                                        paddingRight:30,
                                    }}
                                    >
                                    <Form.Item
                                        name='contact_type'
                                        style={{
                                        display: 'inline-block',
                                        width: 'calc(10% - 12px)',
                                        marginRight: 24,
                                        marginLeft: 14,
                                        }}
                                        
                                    >
                                        <Select
                                            placeholder="请选择联系人方式"
                                            allowClear
                                        >
                                            <Option value="1">电话</Option>
                                            <Option value="2">微信</Option>
                                            <Option value="3">邮箱</Option>
                                            <Option value="4">其他</Option>
                                        </Select>
                                    </Form.Item>
                                    {/* otherWaysContact */}
                                    {/* <Form.Item
                                        name='contact_name'
                                        style={{
                                        display: 'inline-block',
                                        width: 'calc(10% - 12px)',
                                        }}
                                    >
                                        <Input allowClear placeholder="其他联系方式" />
                                    </Form.Item>
                                    <span
                                        style={{
                                        display: 'inline-block',
                                        width: '24px',
                                        lineHeight: '32px',
                                        textAlign: 'center',
                                        }}
                                    >
                                        -
                                    </span> */}

                                    <Form.Item
                                        name='contact_name'
                                        style={{
                                        display: 'inline-block',
                                        width: 'calc(10% - 12px)',
                                        }}
                                    >
                                        <Input allowClear placeholder="联系人姓名" />
                                    </Form.Item>
                                    <span
                                        style={{
                                        display: 'inline-block',
                                        width: '24px',
                                        lineHeight: '32px',
                                        textAlign: 'center',
                                        }}
                                    >
                                        -
                                    </span>
                                    <Form.Item
                                        name='contact_phone'
                                        style={{
                                        display: 'inline-block',
                                        width: 'calc(25% - 12px)',
                                        }}
                                    >
                                        <Input allowClear placeholder="联系人电话" />
                                    </Form.Item>
                                </Form.Item> 
                                {/* 购买渠道 */}
                                <Form.Item
                                    label="采购渠道"
                                    style={{
                                        marginBottom: 0,
                                        width:'50%',
                                        paddingLeft:11
                                    }}
                                    >
                                    
                                    <Form.Item
                                        name='buy_channel'
                                        style={{
                                        display: 'inline-block',
                                        width: 'calc(30% - 12px)',
                                        }}
                                    >
                                        <Input allowClear placeholder="请输入采购渠道" />
                                    </Form.Item>
                                    <span
                                        style={{
                                        display: 'inline-block',
                                        width: '24px',
                                        lineHeight: '32px',
                                        textAlign: 'center',
                                        }}
                                    >
                                        -
                                    </span>
                                    <Form.Item
                                        name='buy_link'
                                        style={{
                                        display: 'inline-block',
                                        width: 'calc(61% - 12px)',
                                        }}
                                    >
                                        <Input allowClear placeholder="采购链接( 若有则填写 )" />
                                    </Form.Item>
                                </Form.Item>       
                                {/* 运输方式 */}
                                <Form.Item
                                    label="运输方式"
                                    style={{
                                        marginBottom: 0,
                                        width:'50%',
                                        paddingLeft:11
                                    }}
                                    >
                                    <Form.Item
                                        name='transport_type'
                                        style={{
                                        display: 'inline-block',
                                        width: 'calc(30% - 12px)',
                                        marginRight: 24,
                                        }}
                                        
                                    >
                                        <Select
                                            placeholder="请选择物流方式"
                                            allowClear
                                        >
                                            <Option value="1">快递</Option>
                                            <Option value="2">物流</Option>
                                            <Option value="3">其他</Option>
                                        </Select>
                                    </Form.Item>
                                    <Form.Item
                                        name='transport_remark'
                                        style={{
                                        display: 'inline-block',
                                        width: 'calc(31% - 12px)',
                                        }}
                                    >
                                        <Input allowClear placeholder="请输入运输方式" />
                                    </Form.Item>
                                </Form.Item> 
                                {/* 分隔符 */}
                                <div className="henLine"></div>
                                {/* 有无配件 /配件信息 */}
                                {wx? '': <>
                                <Row>
                                    <Col span={6}>
                                        <Form.Item name="has_fittings" label="有无配件" onChange={this.hasFittings} rules={[{ required: true, message: '请选择有无配件' }]} >
                                            <Radio.Group disabled={(type == '2' && !wx)}>
                                                <Radio value="1">有配件</Radio>
                                                <Radio value="2">无配件</Radio>
                                            </Radio.Group>
                                        </Form.Item>
                                    </Col>
                                    { type == 1 && ishasFittings == 1 ? 
                                    <Col span={8} offset={1}>
                                        <Form.Item
                                            label="配件信息"
                                            style={{
                                                marginBottom: 0,
                                            }}
                                            className="justOne"
                                            >
                                            <Form.Item
                                                name='cate_id'
                                                style={{
                                                display: 'inline-block',
                                                width: 'calc(50% - 12px)',
                                                // marginRight: 24,
                                                }}
                                            >
                                                <Select placeholder="请选择配件分类" onChange={this.onfsiChange.bind(this)}  allowClear>
                                                    { list.map((val, ind) => ( <Option value={ val.id } key={ val.id }>{ val.cate_name }</Option> ))}
                                                </Select>
                                            </Form.Item>
                                            <span
                                                style={{
                                                display: 'inline-block',
                                                width: '24px',
                                                lineHeight: '32px',
                                                textAlign: 'center',
                                                }}
                                            >
                                                -
                                            </span>
                                            <Form.Item
                                                  name='fitting_spu_id'
                                                style={{
                                                display: 'inline-block',
                                                width: 'calc(50% - 12px)',
                                                }}
                                            >
                                                <Select placeholder="请选择设备编号"  allowClear>
                                                    { spu_arr.map((val, ind) => ( <Option value={ val.spu_id } key={ val.spu_id }>{ val.eq_model }</Option> ))}
                                                </Select>
                                            </Form.Item>
                                        </Form.Item> 
                                    </Col>
                                    : ''}
                                </Row>
                                
                                {/* 分隔符 */}
                                <div className="henLine"></div>
                                {/* 设备创始人、复核人 */}
                                <Row>
                                    <Col span={5}>
                                        {/* 设备创始人 */}
                                        <Form.Item
                                                name="user_name"
                                                label="设备创始人"
                                                rules={[
                                                    {
                                                    required: true,
                                                    },
                                                ]}
                                                >
                                                <Input allowClear placeholder="请输入创始人" disabled />
                                        </Form.Item>
                                    </Col>
                                    <Col span={5} offset={2}>
                                        {/* 复核人 */}
                                        <Form.Item
                                                name="review_u_id"
                                                label="复核人"
                                                labelInValue
                                                rules={[
                                                    {
                                                    required: true,
                                                    },
                                                ]}
                                                >
                                                <Select placeholder="请选择复核人" onChange={this.changeCCr} allowClear>
                                                        { user_list.map((item, ind) => ( <Option value={ item.uid } key={ item.uid }>{ item.user_name }</Option> ))}
                                                </Select>
                                        </Form.Item>    
                                    </Col>
                                </Row>                      
                                </>}
                                <Form.Item>
                                    <Button onClick={this.goBack} htmlType="submit" style={{padding: '8px 24px 28px 24px',borderRadius:'4px',marginLeft:'400px',marginRight:'20px'}}>
                                        取消
                                    </Button>
                                    <Button  onClick={ wx || myDeclare ? this.revise : this.subDeclare}  type="primary" htmlType="submit" style={{padding: '8px 24px 28px 24px', backgroundColor: '#0054FEFF',color:'#fff',borderRadius:'4px',}}>
                                        {wx || myDeclare ? '修改' : '保存'}
                                    </Button>
                                </Form.Item>
                            </Form>
                        </div>
                    </Col>
                </Row>
                {/* modal */}
                <Modal
                    title="设备规格添加" 
                    wrapClassName="EquipmentSpecificationsAdded"
                    visible={addESAModal}
                    closable={false}
                    afterClose={this.afterClose}
                    footer={[
                        <Button style={{backgroundColor:'#334BFC',borderRadius:'4px'}} key="submit" type="primary" onClick={this.reqAddNewGG}>
                          确定
                        </Button>,
                        <Button style={{borderRadius:'4px'}} key="back" onClick={()=>{this.setState({addESAModal:false})}}>
                            取消
                        </Button>
                      ]}
                    >
                    <div className="addCar">
                            <Form ref={this.addCarForm} name="complex-form" className="noC_form" style={{width:'90%'}} >
                                {/* 每种编号 */}
                                <Form.Item
                                    className="formitem"
                                    name="spec_key"
                                    label="规格类别"
                                    labelInValue
                                    >
                                    <Input placeholder="固定方向" disabled></Input>
                                </Form.Item>
                                <Form.Item
                                    name="spec_value"
                                    label="已有规格"
                                    // style={{width:'80%'}}
                                >
                                    <Input  placeholder="请输入" disabled></Input>
                                </Form.Item>
                                <Form.Item
                                    name="spec_value2"
                                    label="新增规格"
                                    // style={{width:'80%'}}
                                >
                                    <Input placeholder="请输入新增规格" ></Input>
                                </Form.Item>
                            </Form>
                        </div>
                </Modal>
            </div>
        )
    }
}

export default addNewType;